﻿#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include "SeqStackLinkStore.h"

struct PersonStackLink
{
	struct StackNode node;
	char name[64];
	int age;
};

void testSeqStackLink()
{
	//10.初始化链式栈；
	LinkStack stack = Init_LinkStack();

	//9.创建数据；
	struct PersonStackLink p1 = { NULL,"aaa",10 };
	struct PersonStackLink p2 = { NULL,"bbb",20 };
	struct PersonStackLink p3 = { NULL,"ccc",30 };
	struct PersonStackLink p4 = { NULL,"ddd",40 };
	struct PersonStackLink p5 = { NULL,"eee",50 };

	//13.数据入栈；
	Push_LinkStack(stack, &p1);
	Push_LinkStack(stack, &p2);
	Push_LinkStack(stack, &p3);
	Push_LinkStack(stack, &p4);
	Push_LinkStack(stack, &p5);

	//14.输出栈中所有的元素；
	while (Size_LinkStack(stack) > 0)
	{
		//15.获取栈顶元素；
		struct PersonStackLink* person = (struct PersonStack*)Top_LinkStack(stack);
		//16.打印输出元素；
		printf("17.输出栈中的顶元素person为Name：%s  Age：%d\n", person->name, person->age);//50,40,30,20,10
		//19.弹出栈顶元素；
		Pop_LinkStack(stack);
	}

	printf("20.输出栈的大小Size：%d\n", Size_LinkStack(stack));//0

	//18.销毁栈；
	Destroy_LinkStack(stack);
	stack = NULL;
}

//main225：栈的链式存储
int main225()
{
	testSeqStackLink();

	system("pause");
	return EXIT_SUCCESS;
}